<script setup>
   import {ref} from 'vue';

   import {useRouter} from 'vue-router'

   let user = ref({
      account:"",
      password:""
   });


   let router = useRouter();

   let login=()=>{
     //账号 root 密码 123456
     if(user.value.account == 'root' && user.value.password == '123456'){
        //1.存储
        // javascript window  localStorage 【多页面共享】 || sessionStorage 【单页面有效】  == java HttpSession 
        window.localStorage.setItem("user",user.value.account);
        //2.跳转
        router.push("/home");
     }else{
        alert("账号或者密码错误！");
     }
   }

</script>

<template>
  <div>

    账号： <input type="text" v-model="user.account" placeholder="请您输入账号 "> <br>
    密码： <input type="text" v-model="user.password" placeholder="请您输入密码"> <br>
    <button @click="login()">登录</button>

  </div>
</template>

<style scoped>

</style>